package com.easy.west.westclient.api.message.api;

import android.content.Context;
import android.support.annotation.NonNull;

import com.easy.west.westclient.api.base.bean.SuccessBean;
import com.easy.west.westclient.api.base.callback.BaseCallBack;
import com.easy.west.westclient.api.base.impl.BaseImpl;
import com.easy.west.westclient.api.message.bean.MessgaeList;
import com.easy.west.westclient.api.message.event.CreateMessageEvent;
import com.easy.west.westclient.api.message.event.FindAllMessage1Event;
import com.easy.west.westclient.api.message.event.FindAllMessage2Event;
import com.easy.west.westclient.api.message.event.FindAllMessageEvent;
import com.easy.west.westclient.api.message.event.ReadMessageEvent;
import com.easy.west.westclient.util.UUIDGenerator;

/**
 * 消息请求
 * Created by xiatao on 2018/8/30.
 */

public class MessageImpl extends BaseImpl<MessageService> implements MessageApi {

    public MessageImpl(@NonNull Context context) {
        super(context);
    }

    /**
     * 注释见接口
     * @param uid 用户id
     * @return
     */
    @Override
    public String findAllMessage(long uid) {
        String uuid = UUIDGenerator.getUUID();
        service.findAllMessage(uid).enqueue(new BaseCallBack<MessgaeList>(new FindAllMessageEvent(uuid)));
        return uuid;
    }

    @Override
    public String createMessage(String title, String content, String type, int userid, int isImportant) {
        String uuid = UUIDGenerator.getUUID();
        service.createMessage(title,content,type,userid,isImportant)
                .enqueue(new BaseCallBack<SuccessBean>(new CreateMessageEvent(uuid)));
        return uuid;
    }

    @Override
    public String readMessage(long isread) {
        String uuid = UUIDGenerator.getUUID();
        service.readMessage(isread).enqueue(new BaseCallBack<SuccessBean>(new ReadMessageEvent(uuid)));
        return uuid;
    }


    /**
     * 注释见接口
     * @param uid 用户id
     * @return
     */
    public String findAllMessage1(long uid) {
        String uuid = UUIDGenerator.getUUID();
        service.findAllMessage(uid).enqueue(new BaseCallBack<MessgaeList>(new FindAllMessage1Event(uuid)));
        return uuid;
    }


    /**
     * 注释见接口
     * @param uid 用户id
     * @return
     */
    public String findAllMessage2(long uid) {
        String uuid = UUIDGenerator.getUUID();
        service.findAllMessage(uid).enqueue(new BaseCallBack<MessgaeList>(new FindAllMessage2Event(uuid)));
        return uuid;
    }


}
